
class P455_39643 {

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

	
	public static void main(String[] args) {
		int cases = Integer.parseInt(readLn());
			for (int k = 0; k < cases; k++) {
				readLn();
				process(readLn());
				
				if (k + 1 != cases) System.out.println();
				
			}
	}


	private static void process(String string) {
		
		for (int k = 1; k < string.length(); k++) {
			String s = string.substring(0, k);
			
			if (isPart(s, string)) {
				System.out.println(s.length());
				return;
			}
				
			
		}
		
		System.out.println(string.length());
		
	}


	private static boolean isPart(String s, String string) {
		
		if (string.length() % s.length() != 0) return false;
		
		int length = string.length() / s.length();
		
		for (int k = 0; k < length; k++) {
			
			if (!s.equals(string.substring(k * s.length(), k * s.length() + s.length()))) 
				return false;
			
		}
		
		return true;
	}
	
	
}
